import React, { PureComponent } from 'react'
import Cart from './pages/Cart'

export class app extends PureComponent {
  constructor() {
    super()

    this.state = {
      isLogin: false,
    }
  }

  loginClick() {
    localStorage.setItem('token', '123')
    // this.setState({ isLogin: true })

    // 强制更新
    this.forceUpdate()
  }

  render() {
    // const { isLogin } = this.state

    return (
      <div>
        App
        {/* {isLogin ? <Cart /> : '请先登录在查看'} */}
        <button onClick={(e) => this.loginClick()}>登录</button>
        <Cart />
      </div>
    )
  }
}

export default app
